One of the functions of an operating system (“OS”) is the load and run executable “images.” These “images” are typically stored files that are designed to be loaded into the memory of a computer. When control of the processor is passed to an “image” in memory, it executes (or “runs”) that image. These may be, for example, applications, programs, program modules, program libraries, and the like. A reference herein to loading files expressly refers to loading stored executable images.
Loaders
It is normally the responsibility of the OS to load executable images into memory, create relevant sections that it understands, and then start executing the program. Typically, the part of the operating system that loads and executes executable images is called an “executable-image loader” (or more simply, a “loader”).
Generally, there are two typical types of loaders: relocating and absolute. The absolute loader is the simplest and quickest of the two. The loader loads a file into memory at the location specified by the beginning portion (i.e., header) of the file; it then passes control to the program. If the memory space specified by the header is currently in use, execution is unable to proceed, and the user must wait until the requested memory becomes free.
The relocating loader will load the program anywhere in memory, altering the various addresses as required to ensure correct referencing. With such a type of relocating loader, the decision as to where in memory the program is placed is done by the OS, not the program's header file. This is more efficient, but introduces a slight overhead in terms of a small delay whilst all the relative offsets are calculated.
Typically, a loader is unnecessary for interpreted languages, as the executable code is built up into the memory of the computer.
Formats of Executable Images
Typically, the loader of an OS supports specific formats of executable images. Below is an example of a typical format for an executable image commonly referred to as an “exe” or “.exe” format. Such format is employed and supported by existing popular brands of OS for personal computers.
